<?php

namespace App\Repository;

use Carbon\Carbon;
use GuzzleHttp\Client;

class ToutiaoRepository
{
    protected $client;

    public function __construct(Client $client)
    {
        $this->client = $client;
    }
    public function  callback($event,$clickId){
        $url="https://analytics.oceanengine.com/api/v2/conversion";
       $retult= $this->client->post($url,[
            'json'=>[
                'event_type'=>$event,
                'context'=>[
                    'ad'=>[
                        'callback'=>$clickId
                    ]
                ],
                'timestamp'=>Carbon::now()->getTimestamp()*1000
            ]
        ]);
       return json_decode($retult->getBody()->getContents(),true);
    }
}
